/*目：设计一个学生类，属性包含姓名年龄和学位，学生类派生出本科生类和研究生类，本科生类增加专业属性，
研究生类增加研究方向属性，每一类都有显示的方法，用于相关属性信息的输出。
 */

package demo;
class Student{
    private String name;//姓名
    private int age;//年龄
    private String degree;//学位

    public Student(String name, int age, String degree) {
        this.name = name;
        this.age = age;
        this.degree = degree;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getDegree() {
        return degree;
    }

    public void setDegree(String degree) {
        this.degree = degree;
    }


    }

//本科生类
class Undergraduate extends Student {
    private String profession;//专业

    public Undergraduate(String name, int age, String degree, String profession) {
        super(name, age, degree);
        this.profession = profession;
    }

    public String getProfession() {
        return profession;
    }

    public void setProfession(String profession) {
        this.profession = profession;
    }
    public void show(){
        System.out.println("姓名："+this.getName()+" 年龄:"+this.getAge()+" 学位:"+this.getDegree()+" 专业:"+this.getProfession());
    }


    }

//研究生类
class GraduateStudent extends Student {
    public GraduateStudent(String name, int age, String degree, String researchDirection) {
        super(name, age, degree);
        this.researchDirection = researchDirection;
    }

    private String researchDirection; //研究方法

    public String getResearchDirection() {
        return researchDirection;
    }

    public void setResearchDirection(String researchDirection) {
        this.researchDirection = researchDirection;
    }
    public void show(){
        System.out.println("姓名："+this.getName()+" 年龄:"+this.getAge()+" 学位:"+this.getDegree()+" 研究方向:"+this.getResearchDirection());
    }
}

public class Test {
    public static void main(String[] args) {
        Undergraduate undergraduate = new Undergraduate("张三", 18, "本科", "Java后端开发");
        GraduateStudent graduateStudent=new GraduateStudent("李四",19,"硕士","Java后端开发");
        undergraduate.show();
        graduateStudent.show();


    }
}
